import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FbaStockVO, FbaStockForm, FbaStockQuery } from '@/api/lingxing/fbaStock/types';

/**
 * 查询领星FBA库存列表
 * @param query
 * @returns {*}
 */

export const listFbaStock = (query?: FbaStockQuery): AxiosPromise<FbaStockVO[]> => {
  return request({
    url: '/lingxing/fbaStock/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询领星FBA库存详细
 * @param id
 */
export const getFbaStock = (id: string | number): AxiosPromise<FbaStockVO> => {
  return request({
    url: '/lingxing/fbaStock/' + id,
    method: 'get'
  });
};

/**
 * 新增领星FBA库存
 * @param data
 */
export const addFbaStock = (data: FbaStockForm) => {
  return request({
    url: '/lingxing/fbaStock',
    method: 'post',
    data: data
  });
};

/**
 * 修改领星FBA库存
 * @param data
 */
export const updateFbaStock = (data: FbaStockForm) => {
  return request({
    url: '/lingxing/fbaStock',
    method: 'put',
    data: data
  });
};

/**
 * 删除领星FBA库存
 * @param id
 */
export const delFbaStock = (id: string | number | Array<string | number>) => {
  return request({
    url: '/lingxing/fbaStock/' + id,
    method: 'delete'
  });
};

/**
 * 同步领星接口
 * @returns {*}
 */
export const syncData = () => {
  return request({
    url: '/lingxing/fbaStock/syncData',
    method: 'post'
  });
};

export const getNewestUpdateTime = () => {
  return request({
    url: '/lingxing/fbaStock/getNewestUpdateTime',
    method: 'get'
  });
};
